package com.jingming.consult.videoplayer;

import android.media.MediaPlayer;

/**
 * 音频播放器管理器.
 */
public class AduioPlayerManager {

    private MediaPlayer mMediaPlayer;
    private int mId;

    private AduioPlayerManager() {
    }

    private static AduioPlayerManager sInstance;

    public static synchronized AduioPlayerManager instance() {
        if (sInstance == null) {
            sInstance = new AduioPlayerManager();
        }
        return sInstance;
    }

    public MediaPlayer getCurrentFrequencyPlayer() {
        return mMediaPlayer;

    }

    public void setCurrentFrequencyPlayer(MediaPlayer mediaPlayer) {
        if (mMediaPlayer != mediaPlayer) {
            releaseFrequencyPlayer();
            mMediaPlayer = mediaPlayer;
        }
    }

    public void setNewsId(int id) {
        if (mId != id) {
            mId = id;
        }
    }

    public int getNewsId() {
        return mId;

    }

    public void releaseFrequencyPlayer() {
        if (mMediaPlayer != null) {
            mMediaPlayer.release();
            mMediaPlayer = null;
        }
    }


}
